/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dds2.serviceSystem.Bl;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import mx.its.dds2.ServicesSystem.Enum.TransactionState;
import mx.its.dds2.ServicesSystem.Modelo.Typeclass;
import mx.its.dds2.serviceSystem.Dao.TypeclassDaoLocal;

/**
 *
 * @author Carlos Asis
 */
@Stateless
public class TypeClass implements TypeClassLocal {

    @EJB
    private TypeclassDaoLocal typeclassDao;

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @Override
    public TransactionState register(Typeclass typeclass) {
        if (typeclassDao.FindDuplecity(typeclass)) {
            return TransactionState.INCOMPLETE;
        } else {
            typeclassDao.create(typeclass);
            return TransactionState.COMPLETE;
        }

    }

    @Override
    public TransactionState modify(Typeclass typeclass) {
        if (typeclass.getId() == null || typeclassDao.find(typeclass.getId()) == null) {
            return TransactionState.INCOMPLETE;
        } else {
            typeclassDao.edit(typeclass);
            return TransactionState.COMPLETE;
        }
    }

//    @Override
//    public TransactionState delete(Typeclass typeclass) {
//        if (typeclass.getId() == null || typeclassDao.find(typeclass.getId()) == null) {
//            return TransactionState.INCOMPLETE;
//        } else {
//            typeclassDao.remove(typeclass);
//            return TransactionState.COMPLETE;
//        }
//    }
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @Override
    public List<Typeclass> getListAll() {
        return typeclassDao.findAll();
    }
}
